require(['./config'], ()=>{
    require(['template','header','footer'], (template)=>{
        class Index {
            constructor(){
                this.banner()
                this. getCategory( )
                this.list()
            }
        banner(){
                console.log('banner')
                //轮播
                    var mySwiper = new Swiper ('.swiper-container', {
                        speed:2500,
                        autoplay: {
                          delay: 2000,
                          disableOnInteraction: false,
                          waitForTransition: false,
                        },
                        //   direction: 'vertical',  垂直切换选项
                        loop: true, // 循环模式选项
                        //   effect : 'cube',
                        // 如果需要分页器
                        keyboard : true,
                        pagination: {
                            el: '.swiper-pagination',
                            clickable :true,
                        },
                        
                        autoplay: {
                            autoplay:true,
                            disableOnInteraction:false,
                        },
                    })                
            }

            getCategory(){
                $.get('/libs/json/homeCategory.json',resp=>{
                    this.renderCategory(resp)
                })             
            } 
            renderCategory(list){
                // console.log(list, '1')
                //第一个参数id名
                //第二个参数一个对象，模板需要的数据
                const html = template('showBuy',{list})  
                // console.log(html)
                $('#categoryList').html(html)
            }  
            list(){
                $.get('http://rap2.taobao.org:38080/app/mock/256888/api/index/list',resp=>{
                    console.log(resp)
                    if(resp.code===200){
                        const {list} = resp.body
                        // console.log(list)
                        $('#cakeList').html(template('cakeTemplate',{list}))
                    }
                })
            }         
        }
        new Index()
    })
})



 